#!/usr/bin/python3
# -*- coding: utf-8 -*-
import threading
import time
from server import Server
server_port = 6699  # 服务器监听端口
sleep_time = 10  # 更新频率
accept_time = 3  # 惰性更新策略，连续几次为通才认为通


if __name__ == '__main__':
    s = Server(server_port, accept_time)
    threading.Thread(target=s.topo_update_loop).start()  # 启动监听线程
    while True:
        new_path = s.path_update()
        if new_path:
            for k, v in new_path.items():
                print('ad_hoc IP:%s, host_IP:%s' % (k, s.get_host_IP(k)))
                print(v)
        time.sleep(sleep_time)
